package demo3;

import java.util.ArrayList;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2024-12-12
 * Time: 11:37
 */
public class Main {
    private Stack<Integer> stack = new Stack<>();
    private Stack<Integer> min = new Stack<>();
    public void push(int node) {
        stack.push(node);
        if (min.size() == 0 || node < min.peek()) {
            min.push(node);
        } else {
            min.push(min.peek());
        }
    }

    public void pop() {
        stack.pop();
        min.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int min() {
        return min.peek();
    }
}
